<template>
    <div class="body">
        <van-cell title="商品评分">
            <template #right-icon>
                <van-rate v-model="product_num" />
            </template>
        </van-cell>
        <van-cell title="服务评分">
            <template #right-icon>
                <van-rate v-model="serve_num" />
            </template>
        </van-cell>
        <van-field
        v-model="comment"
        rows="1"
        autosize
        label="留言"
        type="textarea"
        placeholder="请留下你宝贵的意见，我们将竭诚为你服务"
        />
        <div class="img-content">
            <van-uploader v-model="fileList" multiple :max-count="1" :after-read="afterRead"/>
        </div>
        <van-button type="primary" size="large" class="sub-btn" @click="submit">提交</van-button>
    </div>
</template>
<script>
import {GoodsReply} from '../ajax'
import {Toast} from 'vant'
export default {
    data() {
        return {
            serve_num: 5,
            fileList: [],
            product_num:5,
            image:'',
            comment:''
        }
    },
    methods:{
        afterRead(file) {
            // 此时可以自行将文件上传至服务器
            console.log(file);
            this.image = file.file;
        },
        submit(){
            const data = {
                goods_id:this.$route.query.product_id,
                admin_id:this.$store.getters.admin_id,
                comment:this.comment,
                image:this.image,
                uid:this.$store.getters.wxUserInfo.id,
                oid:this.$route.query.oid,
                goods_score:this.product_num,
                service_score:this.serve_num
            }
            GoodsReply(data).then(res=>{
                console.log(res);
                Toast('评论完成');
                history.go(-1);
            })
        }
    }
}
</script>
<style scoped lang='scss'>
    .body{
        height: calc(100vh - 3rem);
        .van-cell__title{
            font-size: 1rem;
            font-weight: 500;
        }
        .img-content{
            padding: 1rem;
        }
        .sub-btn{
            position: absolute;
            bottom: 0;
        }
    }
</style>